<!-- 热门课程排行榜 -->
<template>
  <div class="hot-course-ranking">
    <button class="back-button" @click="$router.back()">
      ← 返回
    </button>
    <!-- 热门课程排行榜 -->
    <section class="ranking-section">
      <h2 class="section-title">热门课程排行榜</h2>
      <div class="course-list">
        <router-link 
          v-for="(course, index) in hotCourses" 
          :key="course.title" 
          :to="{ name: 'CourseDetail', params: { id: course.id } }"
          class="course-item"
        >
          <div class="top-badge" v-if="index < 3">
            <span>TOP {{ index + 1 }}</span>
          </div>
          <img src="@/assets/background.jpg" alt="Course Image" class="course-image" />
          <div class="course-info">
            <h4>{{ course.title }}</h4>
            <p class="price">¥{{ course.price }}</p>
          </div>
        </router-link>
      </div>
    </section>

    <!-- 24小时热销课程 -->
    <section class="hot24-section">
      <h2 class="section-title">24小时热销课程</h2>
      <div class="course-list">
        <router-link 
          v-for="(course, index) in top24hCourses" 
          :key="course.title" 
          :to="{ name: 'CourseDetail', params: { id: course.id } }"
          class="course-item"
        >
          <img src="@/assets/background.jpg" alt="Course Image" class="course-image" />
          <div class="course-info">
            <h4>{{ course.title }}</h4>
            <p class="price">¥{{ course.price }}</p>
          </div>
        </router-link>
      </div>
    </section>
  </div>
</template>

<script>
export default {
  data() {
    return {
      hotCourses: [
        { id: 1, title: '一元二次方程', price: 125 },
        { id: 2, title: '高考英语全解', price: 228 },
        { id: 3, title: '语文作文写作技巧', price: 69 },
        { id: 4, title: '小学英语', price: 26 },
        { id: 5, title: '奥数的秘密', price: 319 }
      ],
      top24hCourses: [
        { id: 2, title: '高考英语全解', price: 228 },
        { id: 5, title: '奥数的秘密', price: 319 },
        { id: 1, title: '一元二次方程', price: 125 }
      ]
    };
  }
};
</script>

<style scoped>
.hot-course-ranking {
  position: relative;
  background-color: #f0f4f8;
  padding: 40px;
  text-align: center;
}

/* 区块容器 */
.ranking-section,
.hot24-section {
  background-color: #fff;
  border-radius: 16px;
  padding: 30px;
  margin-bottom: 40px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

/* 标题 */
.section-title {
  font-size: 24px;
  color: #333;
  margin-bottom: 20px;
  font-weight: bold;
}

/* 课程列表 */
.course-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-around;
  gap: 20px;
}
.back-button:hover {
   background-color: #337ab7;
  color: white;
}

/* 课程项 */
.course-item {
  position: relative;
  width: calc(20% - 16px);
  min-width: 150px;
  background-color: #fff;
  border-radius: 8px;
  overflow: hidden;
  transition: transform 0.3s;
}

.course-item:hover {
  transform: translateY(-5px);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.1);
}

/* TOP 徽章 */
.top-badge {
  position: absolute;
  top: -10px;
  left: -10px;
  background-color: #d9534f;
  color: #fff;
  padding: 5px 10px;
  border-bottom-right-radius: 5px;
  font-size: 14px;
  font-weight: bold;
}

/* 课程图片 */
.course-image {
  width: 100%;
  height: 150px;
  object-fit: cover;
  margin-bottom: 10px;
}

/* 课程信息 */
.course-info h4 {
  font-size: 16px;
  margin: 10px 0;
  color: #333;
}

.course-info .price {
  color: #e74c3c;
  font-size: 18px;
  font-weight: bold;
}
.back-button {
  position: absolute;
  top: 20px;
  right: 20px;
  background-color: #ffffff;
  color: #337ab7;
  border: 2px solid #337ab7;
  padding: 10px 20px;
  font-size: 16px;
  font-weight: bold;
  border-radius: 30px;
  cursor: pointer;
  z-index: 10;
  transition: all 0.3s ease;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

/* 24小时热销特殊样式 */
.hot24-section .course-item {
  background-color: #f9f9f9;
}
</style>